package com.ruoyi.cms.controller.portal;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cms.entity.req.MyLikeListReq;
import com.ruoyi.cms.entity.resp.ModelListResp;
import com.ruoyi.cms.service.ModelLikesService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 模型点赞
 */
@RestController
@RequestMapping("/portal/cms/modelLikes")
public class ModelLikesController {

    @Autowired
    private ModelLikesService modelLikesService;

    /**
     * 点赞
     */
    @GetMapping("/like")
    public R<Integer> like(@RequestParam Long modelId) {
        return modelLikesService.like(modelId);
    }

    /**
     * 取消点赞
     */
    @GetMapping("/cancelLike")
    public R<Integer> cancelLike(@RequestParam Long modelId) {
        return modelLikesService.cancelLike(modelId);
    }

    /**
     * 是否点赞
     */
    @GetMapping("/isLike")
    public R<Boolean> isLike(@RequestParam Long modelId) {
        return R.ok(modelLikesService.getLikeList().contains(modelId));
    }

    /**
     * 我的点赞模型作品列表
     */
    @PostMapping("/myLikeList")
    public R<Page<ModelListResp>> myLikeList(@RequestBody MyLikeListReq req) {
        return modelLikesService.myLikeList(req);
    }


}
